package com.lepu.app.fun.index.bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

public class BeanWriter implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public String ArticleID;
	public String ArticleTitle;
	public String ArticleDescription;
	public String ArticleTag;
	public String PublishDate;
	public String Cover;
	public String LinkURL;
	public String LinkTargetType;
	public String LinkTargetID;
	public String ViewCount;
	public String CommentCount;
	public String FavourCount;
	
	public static ArrayList<BeanWriter> parseJsonData(String dataString) {
		String result = "";
		try {
			JSONObject jsonObject = new JSONObject(dataString);
			JSONObject obj1 = (JSONObject) jsonObject.get("Result");
			JSONArray obj2 = (JSONArray) obj1.getJSONArray("ListInfo");

			result = obj2.toString();
		} catch (JSONException e) {
			e.printStackTrace();
		}

		Gson gson = new Gson();
		ArrayList<BeanWriter> testArraylist = gson.fromJson(result,new TypeToken<List<BeanWriter>>() {
				}.getType());
		return testArraylist;
	}
	
}
